parser grammar BlocksParser;

options {
  language = Java;
  tokenVocab = BlocksLexer;
  output = AST;
}

tokens {
  SPEC; 
  BLOCKS;
  MAPPINGS;
}

@header {
package org.moflon.moca.blocks.parser; 
}
// parser rules:
main: block* mapping*
    -> ^(SPEC ^(BLOCKS block*) ^(MAPPINGS mapping*));

block: START OPEN name=STRING CLOSE port* STOP OPEN STRING CLOSE
    -> ^($name port*); 

port: PORT DOT INTEGER
    -> INTEGER;

mapping: from=INTEGER TO to=INTEGER
      -> ^($from $to); 
